import static org.junit.Assert.*;

import org.junit.Test;

public class interface_not_thread_safe_test {
  @Test
  public void test() {
    unsafe_counter counter = new unsafe_counter();

    int threads = 20;
    Thread[] workers = new Thread[threads];

    for (int i = 0; i < threads; i++) {
      workers[i] = new Thread(() -> interface_not_thread_safe.foo(counter));
    }

    for (Thread t : workers)
      t.start();
    for (Thread t : workers) {
      try {
        t.join();
      } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
      }
    }

    assertEquals(20, counter.get_counter());
  }
}
